import { defineStore } from "pinia";

/*
 * @Author: cl
 * @Description: 用户模块
 * @Date: 2023-05-04 09:39:14
 * @LastEditTime: 2023-05-04 11:11:35
 * @FilePath: \vue3\src\store\user.ts
 * @LastEditors: cl
 */
import { getToken, removeToken } from "../utils/auth";
import * as loginApi from "@/api/moudules/user.js";

const userStore = defineStore("myuser", {
  state: () => ({
    token: getToken(),
  }),
  actions:{
    userlogin(userInfo:any) {
      return new Promise((resolve, reject) => {
        loginApi.login(userInfo).then((res:any) => {
          if (res.status == 0) {
            resolve(res);
          } else {
            reject(new Error("登陆失败"));
          }
        });
      });
    },
  },
});

export {
  userStore
}
